package main

import (
	"io/ioutil"
	"crypto/md5"
	"fmt"
	"bytes"
	"os"
)

func getFileBytes(fileName string) ([]byte, error) {
	bytes, err := ioutil.ReadFile(fileName)
	return bytes, err
}

func getFileMd5(file string) string {
	data, err := ioutil.ReadFile(file)
	if err != nil {
		panic(err)
	}
	md5Bytes := md5.Sum(data)

	var buf bytes.Buffer

	for _, s := range md5Bytes {
		buf.WriteString(fmt.Sprintf("%02x", s))
	}
	return buf.String()
}

func getFileSize(file string) int64 {
	info, err := os.Stat(file)
	if err != nil {
		panic(err)
	}

	return info.Size()
}
